from django.db import models

# Create your models here.
class BlogPost(models.Model):
	title = models.CharField(maxlength=100)
	blurb = models.CharField(maxlength=300)
	article = models.CharField(maxlength=15000)
	publisheddate = models.DateTimeField('Date Published')
	published = models.BooleanField()
	author = models.CharField(maxlength=30)
	# String output for class
	def __str__(self):
		return self.title
	#Was this article published in the last 30 days?
	def due_this_month(self):
		return (datetime.date.today() - self.publisheddate)<30

	class Admin:
		fields = (
			('Post information', {'fields': ('title', 'author', 'blurb', 'publisheddate','published')}),
			('Article', {'fields': ('article',)}),
		)
		list_display = ('title', 'published', 'publisheddate')
		list_filter = ['publisheddate']
		search_fields = ['title', 'author', 'blurb', 'article']
		date_hierarchy = 'publisheddate'
		
